@echo off

SET serv=10.255.254.3
set localdrive=c:
set remotedrive=n:
SET v8exe=%localdrive%\Program Files\1cv82\8.2.19.83\bin\1cv8.exe
set log=%localdrive%\backup.log
set adminuser=/N backup /P avt747556

echo ////////////// START backup %date% %time:~0,2%:%time:~3,2% ////////////////// >> %log%
echo Отключаем все сетевые диски для избавления коллизий во время подключения следующего
net use * /delete /yes
echo  Подключаем сетевой диск
net use %remotedrive% \\10.255.254.2\backup\1c\1c8.2 /user:1cbackup avt747556


SET /A P=1

:1

SET Base=BuhStrOrg

SET BasePath=/S %serv%\%base%

GOTO STARTBACKUP

:2

SET Base=UKTSZH

SET BasePath=/S %serv%\%base%

GOTO STARTBACKUP

:3

SET Base=zup

SET BasePath=/S %serv%\%base%

GOTO STARTBACKUP

:4

SET Base=zupsuk

SET BasePath=/S %serv%\%base%

GOTO STARTBACKUP

:5

SET Base=parking

SET BasePath=/S %serv%\%base%

GOTO STARTBACKUP

::Это конечная метка
:6

GOTO ENDBACKUP

:STARTBACKUP

echo. >> %log%
echo ============ add events in logfile - start %base% ============
echo ============ START %Base% %date% %time:~0,2%:%time:~3,2% ================== >> %log%
IF exist %localdrive%\%base% ( echo %localdrive%\%base% exists ) ELSE ( mkdir %localdrive%\%base% && echo %localdrive%\%base% created)

echo Выгоняю пользователей из базы %Base% и запрещаю в ней работу

start "" /wait "%v8exe%" ENTERPRISE %BasePath% %adminuser% /DisableStartupMessages /C ЗавершитьРаботуПользователей /OUT "%log%" -NoTruncate

echo Делаю архивную копию ИБ

start "" /wait "%v8exe%" CONFIG %BasePath% /DisableStartupMessages /DumpIB "%localdrive%\%base%\1c82_%base%_%date%.dt" %adminuser% /UC КодРазрешения /OUT"%log%" -NoTruncate

echo Разрешаю работать с ИБ дальше

start "" /wait "%v8exe%" ENTERPRISE %BasePath% %adminuser% /DisableStartupMessages /C РазрешитьРаботуПользователей /UC КодРазрешения  /OUT"%log%" -NoTruncate
echo ============ END %Base% %date% %time:~0,2%:%time:~3,2% ================== >> %log%
echo. >> %localdrive%\%log%

move %localdrive%\%base%\*.dt %remotedrive%\%base%\

SET /A P=P+1

GOTO %P%

:ENDBACKUP
echo \\\\\\\\\\\\\\\\ END backup %date% %time:~0,2%:%time:~3,2% \\\\\\\\\\\\\\ >> %log%
echo Копируем лог
copy %log% %remotedrive% /y

echo Отмонтируем сетевой диск
net use %remotedrive% /d /Y